package my.jwds.p104;

import my.jwds.p94.TreeNode;

import java.util.Map;

public class MaxDepth {
    public static void main(String[] args) {
        MaxDepth o = new MaxDepth();
        TreeNode node = TreeNode.to_binaryHaveNull(new Integer[]{3,9,20,null,null,15,7});
        System.out.println(o.maxDepth(node));
    }

    public int maxDepth(TreeNode root) {
        return maxDepth(root,0);
    }


    public int maxDepth(TreeNode node,int tier){
        if (node == null){
            return tier;
        }
        tier++;
        int leftTier = maxDepth(node.left,tier);
        int rightTier = maxDepth(node.right,tier);
        return  leftTier> rightTier?leftTier:rightTier;
    }

}
